package be.bonamis.umpire.domain.history;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.apache.openjpa.persistence.Externalizer;
import org.apache.openjpa.persistence.Factory;
import org.apache.openjpa.persistence.Persistent;
import org.joda.time.DateTime;

import be.bonamis.umpire.domain.Club;
import be.bonamis.umpire.domain.Umpire;

@Entity
public class Game {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;
	@Persistent
	@Externalizer("toDate")
	@Factory("Game.dateTimeToJoda")
	private DateTime gameDay;
	@ManyToOne
	@JoinColumn
	private DivisionType type;
	@ManyToOne
	@JoinColumn
	private Umpire umpire01;
	@ManyToOne
	@JoinColumn
	private Umpire umpire02;
	@ManyToOne
	@JoinColumn
	private Club homeClub;
	@ManyToOne
	@JoinColumn
	private Club awayClub;
//	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
//	@JoinColumn
//	private FairPlayReport fpReportUmpire01;
//	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
//	@JoinColumn
//	private FairPlayReport fpReportUmpire02;
//	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
//	@JoinColumn
//	private FairPlayReport fpReportUmpire03;
//	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
//	@JoinColumn
//	private FairPlayReport fpReportUmpire04;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public DateTime getGameDay() {
		return gameDay;
	}

	public void setGameDay(DateTime gameDay) {
		this.gameDay = gameDay;
	}

	public DivisionType getType() {
		return type;
	}

	public void setType(DivisionType type) {
		this.type = type;
	}

	public Umpire getUmpire01() {
		return umpire01;
	}

	public void setUmpire01(Umpire umpire01) {
		this.umpire01 = umpire01;
	}

	public Umpire getUmpire02() {
		return umpire02;
	}

	public void setUmpire02(Umpire umpire02) {
		this.umpire02 = umpire02;
	}

	public Club getHomeClub() {
		return homeClub;
	}

	public void setHomeClub(Club homeClub) {
		this.homeClub = homeClub;
	}

	public Club getAwayClub() {
		return awayClub;
	}

	public void setAwayClub(Club awayClub) {
		this.awayClub = awayClub;
	}

	public static DateTime dateTimeToJoda(Date dateTime) {
		return new DateTime(dateTime);
	}

}
